package com.budgetme.database;

import android.net.Uri;
import android.provider.BaseColumns;


public class Database {
	public static final String AUTHORITY = "com.budgetme.database.Provider";
	private static final String SCHEME = "content://";
	
	
	static interface table {
		static final String _id = "_id";
	}
	
	public static final class tbl_budgets implements table {
		private tbl_budgets() {}
		
		public static final String NAME = "tbl_budgets";
		
		public static final String PATH = "budgets";
		public static final Uri CONTENT_URI =  Uri.parse(SCHEME + AUTHORITY + "/" + PATH);
		
		public static final int LIFECYCLE_WEEKLY = 1;
		public static final int LIFECYCLE_MONTHLY = 2;
		public static final int LIFECYCLE_QUARTERLY = 3;
		public static final int LIFECYCLE_YEARLY = 4;
		
		public static final int FILTER_ALL = 1;
		public static final int FILTER_ENABLED = 2;
		public static final int FILTER_DISABLED = 3;
		
		public static final String CREATE = "CREATE TABLE tbl_budgets (_id INTEGER PRIMARY KEY AUTOINCREMENT, t_name TEXT, t_lifecycle INTEGER, t_budget REAL DEFAULT 0.0, t_enabled INTEGER default 1, UNIQUE(t_name));";
		public static final String DROP = "DROP TABLE IF EXISTS tbl_budgets";
		
		public static final String t_name = "t_name";
		public static final String t_lifecycle = "t_lifecycle";
		public static final String t_budget = "t_budget";
		public static final String t_enabled = "t_enabled";
		
	}
	
//    public static final class tbl_buckets implements table {
//    	private tbl_buckets() {}
//    	
//    	public static final String NAME = "tbl_buckets";
//    	
//    	public static final String PATH = "buckets";
//    	public static final Uri CONTENT_URI =  Uri.parse(SCHEME + AUTHORITY + "/" + PATH);
//    	
//    	public static final String CREATE = "CREATE TABLE tbl_buckets (_id INTEGER PRIMARY KEY AUTOINCREMENT, t_id INTEGER NOT NULL, b_cycle TEXT);";
//    	public static final String DROP = "DROP TABLE IF EXISTS tbl_buckets";
//    	
//    	public static final String t_id = "t_id";
//    	public static final String b_cycle = "b_cycle";
//    	
//    }
    
    public static final class tbl_expenses implements table {
    	private tbl_expenses() {}
    	
    	public static final String NAME = "tbl_expenses";
    	
    	public static final String PATH = "expenses";
    	public static final Uri CONTENT_URI =  Uri.parse(SCHEME + AUTHORITY + "/" + PATH);
    	
    	public static final String CREATE = "CREATE TABLE tbl_expenses (_id INTEGER PRIMARY KEY AUTOINCREMENT, b_id INTEGER, e_date TEXT, e_amount REAL);";
    	public static final String DROP = "DROP TABLE IF EXISTS tbl_expenses";
    	
    	public static final String b_id = "b_id";
    	public static final String e_date = "e_date";
    	public static final String e_amount = "e_amount";
    	
    }
    
    public static final class tbl_income implements table {
    	private tbl_income() {}
    	
    	public static final String NAME = "tbl_income";
    	
    	public static final String PATH = "income";
    	public static final Uri CONTENT_URI =  Uri.parse(SCHEME + AUTHORITY + "/" + PATH);
    	
    	public static final String CREATE = "CREATE TABLE tbl_income (_id INTEGER PRIMARY KEY AUTOINCREMENT, i_name TEXT, i_amount REAL);";
    	public static final String DROP = "DROP TABLE IF EXISTS tbl_income";
    	
    	public static final String i_name = "i_name";
    	public static final String i_amount = "i_amount";
    	
    }
    
    public static final class v_expenses_budget {
    	private v_expenses_budget() {}
    	
    	public static final String NAME = "v_expenses_budget";
    	
    	public static final String CREATE = "CREATE VIEW v_expenses_budget AS SELECT * FROM tbl_expenses LEFT OUTER JOIN tbl_budgets ON tbl_expenses.b_id=tbl_budgets._id ORDER BY datetime(e_date) desc;";
    	public static final String DROP = "DROP VIEW IF EXISTS v_expenses_budget";
    }
    

	public static final String[] PRELOAD = {
		"INSERT INTO tbl_budgets (_id, t_name, t_lifecycle, t_budget, t_enabled) VALUES (1, 'test budget e1', 2, '125', 1);",
		"INSERT INTO tbl_budgets (_id, t_name, t_lifecycle, t_budget, t_enabled) VALUES (2, 'test budget e2', 2, '225', 1);",
		"INSERT INTO tbl_budgets (_id, t_name, t_lifecycle, t_budget, t_enabled) VALUES (3, 'test budget e3', 2, '325', 1);",
		"INSERT INTO tbl_budgets (_id, t_name, t_lifecycle, t_budget, t_enabled) VALUES (4, 'test budget d1', 2, '125', 0);",
		"INSERT INTO tbl_budgets (_id, t_name, t_lifecycle, t_budget, t_enabled) VALUES (5, 'test budget d2', 2, '225', 0);",
		"INSERT INTO tbl_budgets (_id, t_name, t_lifecycle, t_budget, t_enabled) VALUES (6, 'test budget d3', 2, '325', 0);",

//		"INSERT INTO tbl_buckets (_id, t_id, b_cycle) VALUES (1, 1, '2012-12-09');",
//		"INSERT INTO tbl_buckets (_id, t_id, b_cycle) VALUES (2, 2, '2012-12-16');",
//		"INSERT INTO tbl_buckets (_id, t_id, b_cycle) VALUES (3, 3, '2012-12-23');",

		"INSERT INTO tbl_expenses (b_id, e_date, e_amount) VALUES (1, '2013-07-01 01:01', 5.00);",
		"INSERT INTO tbl_expenses (b_id, e_date, e_amount) VALUES (1, '2013-07-03 10:02', 10.00);",
		"INSERT INTO tbl_expenses (b_id, e_date, e_amount) VALUES (1, '2013-07-04 19:33', 10.00);",
		"INSERT INTO tbl_expenses (b_id, e_date, e_amount) VALUES (1, '2013-07-05 10:01', 5.00);",
		"INSERT INTO tbl_expenses (b_id, e_date, e_amount) VALUES (1, '2013-07-06 10:02', 1.00);",
		"INSERT INTO tbl_expenses (b_id, e_date, e_amount) VALUES (1, '2013-07-07 10:03', 10.00);",
		"INSERT INTO tbl_expenses (b_id, e_date, e_amount) VALUES (1, '2013-07-08 10:01', 1.00);",
		"INSERT INTO tbl_expenses (b_id, e_date, e_amount) VALUES (1, '2013-07-09 10:02', 5.00);",
		"INSERT INTO tbl_expenses (b_id, e_date, e_amount) VALUES (1, '2013-07-10 01:01', 1.00);",
		"INSERT INTO tbl_expenses (b_id, e_date, e_amount) VALUES (1, '2013-07-11 10:02', 10.00);",
		"INSERT INTO tbl_expenses (b_id, e_date, e_amount) VALUES (1, '2013-07-12 10:03', 1.00);",
		"INSERT INTO tbl_expenses (b_id, e_date, e_amount) VALUES (1, '2013-07-13 10:01', 5.00);",
		"INSERT INTO tbl_expenses (b_id, e_date, e_amount) VALUES (1, '2013-07-14 10:02', 10.00);",
		"INSERT INTO tbl_expenses (b_id, e_date, e_amount) VALUES (1, '2013-07-15 10:03', 1.00);",
		"INSERT INTO tbl_expenses (b_id, e_date, e_amount) VALUES (1, '2013-07-16 10:01', 5.00);",
		"INSERT INTO tbl_expenses (b_id, e_date, e_amount) VALUES (1, '2013-07-17 10:02', 5.00);",
		"INSERT INTO tbl_expenses (b_id, e_date, e_amount) VALUES (1, '2013-07-18 01:01', 1.00);",
		"INSERT INTO tbl_expenses (b_id, e_date, e_amount) VALUES (1, '2013-07-19 10:02', 10.00);",
		"INSERT INTO tbl_expenses (b_id, e_date, e_amount) VALUES (1, '2013-07-20 10:03', 1.00);",
		"INSERT INTO tbl_expenses (b_id, e_date, e_amount) VALUES (1, '2013-07-21 10:01', 5.00);",
		"INSERT INTO tbl_expenses (b_id, e_date, e_amount) VALUES (1, '2013-07-22 10:02', 10.00);",
		"INSERT INTO tbl_expenses (b_id, e_date, e_amount) VALUES (1, '2013-07-23 10:03', 1.00);",
		"INSERT INTO tbl_expenses (b_id, e_date, e_amount) VALUES (1, '2013-07-24 10:01', 4.00);",
		"INSERT INTO tbl_expenses (b_id, e_date, e_amount) VALUES (1, '2013-07-25 10:02', 4.00);",
		"INSERT INTO tbl_expenses (b_id, e_date, e_amount) VALUES (1, '2013-07-26 10:01', 4.00);",
		"INSERT INTO tbl_expenses (b_id, e_date, e_amount) VALUES (1, '2013-07-27 10:02', 4.00);",
		"INSERT INTO tbl_expenses (b_id, e_date, e_amount) VALUES (1, '2013-07-28 10:03', 4.00);",
		"INSERT INTO tbl_expenses (b_id, e_date, e_amount) VALUES (1, '2013-07-29 10:01', 4.00);",
		"INSERT INTO tbl_expenses (b_id, e_date, e_amount) VALUES (1, '2013-07-30 10:02', 4.00);",
		"INSERT INTO tbl_expenses (b_id, e_date, e_amount) VALUES (1, '2013-07-31 10:02', 4.00);",
		"INSERT INTO tbl_expenses (b_id, e_date, e_amount) VALUES (2, '2013-08-26 10:04', 10.00);",
		"INSERT INTO tbl_expenses (b_id, e_date, e_amount) VALUES (2, '2013-08-27 10:05', 10.00);",
		"INSERT INTO tbl_expenses (b_id, e_date, e_amount) VALUES (2, '2013-08-28 10:06', 10.00);",
		"INSERT INTO tbl_expenses (b_id, e_date, e_amount) VALUES (3, '2013-08-23 10:07', 10.00);",
		"INSERT INTO tbl_expenses (b_id, e_date, e_amount) VALUES (3, '2013-08-23 10:08', 10.00);",
		"INSERT INTO tbl_expenses (b_id, e_date, e_amount) VALUES (3, '2013-08-23 10:09', 10.00);",
		"INSERT INTO tbl_expenses (b_id, e_date, e_amount) VALUES (3, '2013-08-23 10:10', 10.00);",


		"INSERT INTO tbl_income (i_name, i_amount) VALUES ('test income1', '13854.84');",
		"INSERT INTO tbl_income (i_name, i_amount) VALUES ('test income2', '10000.00');",
		"INSERT INTO tbl_income (i_name, i_amount) VALUES ('test income3', '10000.00');",
		"INSERT INTO tbl_income (i_name, i_amount) VALUES ('test income4', '10000.00');",
		"INSERT INTO tbl_income (i_name, i_amount) VALUES ('test income5', '10000.00');"
		
	};




}


